package com.newture.lxz.admin.controller;

import com.newture.lxz.controller.CourtAddressController;
import com.newture.lxz.errors.AppException;
import com.newture.lxz.errors.Errors;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Locale;

/**
 * @author xiao.hu
 * @date 2021-09-27
 * @apiNote
 */
@Controller
@RequestMapping("/admin/admin")
public class AdminController {
    Logger logger = LogManager.getLogger(CourtAddressController.class);

    @Autowired
    private MessageSource messageSource;

    /**
     * 测试统一异常处理
     */
    @GetMapping("/exception")
    @ResponseBody
    public void exception() {
        logger.debug(messageSource.getMessage(Errors.INTERNAL_ERROR.name(), null, Locale.getDefault()));
        throw new AppException(Errors.INTERNAL_ERROR.name(), "No Parameter In AdminController", "Test AdminController exception");
    }
}
